import {r as A, n as V, p as U} from "./index.e87dab9b.js";

(function () {
    if (typeof window != "object") return;
    if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
        "isIntersecting" in window.IntersectionObserverEntry.prototype || Object.defineProperty(window.IntersectionObserverEntry.prototype, "isIntersecting", {
            get: function () {
                return this.intersectionRatio > 0
            }
        });
        return
    }

    function s(t) {
        try {
            return t.defaultView && t.defaultView.frameElement || null
        } catch {
            return null
        }
    }

    var u = function (t) {
        for (var e = t, r = s(e); r;) e = r.ownerDocument, r = s(e);
        return e
    }(window.document), a = [], c = null, h = null;

    function d(t) {
        this.time = t.time, this.target = t.target, this.rootBounds = m(t.rootBounds), this.boundingClientRect = m(t.boundingClientRect), this.intersectionRect = m(t.intersectionRect || p()), this.isIntersecting = !!t.intersectionRect;
        var e = this.boundingClientRect, r = e.width * e.height, n = this.intersectionRect, i = n.width * n.height;
        r ? this.intersectionRatio = Number((i / r).toFixed(4)) : this.intersectionRatio = this.isIntersecting ? 1 : 0
    }

    function o(t, e) {
        var r = e || {};
        if (typeof t != "function") throw new Error("callback must be a function");
        if (r.root && r.root.nodeType != 1 && r.root.nodeType != 9) throw new Error("root must be a Document or Element");
        this._checkForIntersections = I(this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT), this._callback = t, this._observationTargets = [], this._queuedEntries = [], this._rootMarginValues = this._parseRootMargin(r.rootMargin), this.thresholds = this._initThresholds(r.threshold), this.root = r.root || null, this.rootMargin = this._rootMarginValues.map(function (n) {
            return n.value + n.unit
        }).join(" "), this._monitoringDocuments = [], this._monitoringUnsubscribes = []
    }

    o.prototype.THROTTLE_TIMEOUT = 100, o.prototype.POLL_INTERVAL = null, o.prototype.USE_MUTATION_OBSERVER = !0, o._setupCrossOriginUpdater = function () {
        return c || (c = function (t, e) {
            !t || !e ? h = p() : h = E(t, e), a.forEach(function (r) {
                r._checkForIntersections()
            })
        }), c
    }, o._resetCrossOriginUpdater = function () {
        c = null, h = null
    }, o.prototype.observe = function (t) {
        var e = this._observationTargets.some(function (r) {
            return r.element == t
        });
        if (!e) {
            if (!(t && t.nodeType == 1)) throw new Error("target must be an Element");
            this._registerInstance(), this._observationTargets.push({
                element: t,
                entry: null
            }), this._monitorIntersections(t.ownerDocument), this._checkForIntersections()
        }
    }, o.prototype.unobserve = function (t) {
        this._observationTargets = this._observationTargets.filter(function (e) {
            return e.element != t
        }), this._unmonitorIntersections(t.ownerDocument), this._observationTargets.length == 0 && this._unregisterInstance()
    }, o.prototype.disconnect = function () {
        this._observationTargets = [], this._unmonitorAllIntersections(), this._unregisterInstance()
    }, o.prototype.takeRecords = function () {
        var t = this._queuedEntries.slice();
        return this._queuedEntries = [], t
    }, o.prototype._initThresholds = function (t) {
        var e = t || [0];
        return Array.isArray(e) || (e = [e]), e.sort().filter(function (r, n, i) {
            if (typeof r != "number" || isNaN(r) || r < 0 || r > 1) throw new Error("threshold must be a number between 0 and 1 inclusively");
            return r !== i[n - 1]
        })
    }, o.prototype._parseRootMargin = function (t) {
        var e = t || "0px", r = e.split(/\s+/).map(function (n) {
            var i = /^(-?\d*\.?\d+)(px|%)$/.exec(n);
            if (!i) throw new Error("rootMargin must be specified in pixels or percent");
            return {value: parseFloat(i[1]), unit: i[2]}
        });
        return r[1] = r[1] || r[0], r[2] = r[2] || r[0], r[3] = r[3] || r[1], r
    }, o.prototype._monitorIntersections = function (t) {
        var e = t.defaultView;
        if (!!e && this._monitoringDocuments.indexOf(t) == -1) {
            var r = this._checkForIntersections, n = null, i = null;
            this.POLL_INTERVAL ? n = e.setInterval(r, this.POLL_INTERVAL) : (y(e, "resize", r, !0), y(t, "scroll", r, !0), this.USE_MUTATION_OBSERVER && "MutationObserver" in e && (i = new e.MutationObserver(r), i.observe(t, {
                attributes: !0,
                childList: !0,
                characterData: !0,
                subtree: !0
            }))), this._monitoringDocuments.push(t), this._monitoringUnsubscribes.push(function () {
                var v = t.defaultView;
                v && (n && v.clearInterval(n), R(v, "resize", r, !0)), R(t, "scroll", r, !0), i && i.disconnect()
            });
            var f = this.root && (this.root.ownerDocument || this.root) || u;
            if (t != f) {
                var l = s(t);
                l && this._monitorIntersections(l.ownerDocument)
            }
        }
    }, o.prototype._unmonitorIntersections = function (t) {
        var e = this._monitoringDocuments.indexOf(t);
        if (e != -1) {
            var r = this.root && (this.root.ownerDocument || this.root) || u,
                n = this._observationTargets.some(function (l) {
                    var v = l.element.ownerDocument;
                    if (v == t) return !0;
                    for (; v && v != r;) {
                        var g = s(v);
                        if (v = g && g.ownerDocument, v == t) return !0
                    }
                    return !1
                });
            if (!n) {
                var i = this._monitoringUnsubscribes[e];
                if (this._monitoringDocuments.splice(e, 1), this._monitoringUnsubscribes.splice(e, 1), i(), t != r) {
                    var f = s(t);
                    f && this._unmonitorIntersections(f.ownerDocument)
                }
            }
        }
    }, o.prototype._unmonitorAllIntersections = function () {
        var t = this._monitoringUnsubscribes.slice(0);
        this._monitoringDocuments.length = 0, this._monitoringUnsubscribes.length = 0;
        for (var e = 0; e < t.length; e++) t[e]()
    }, o.prototype._checkForIntersections = function () {
        if (!(!this.root && c && !h)) {
            var t = this._rootIsInDom(), e = t ? this._getRootRect() : p();
            this._observationTargets.forEach(function (r) {
                var n = r.element, i = w(n), f = this._rootContainsTarget(n), l = r.entry,
                    v = t && f && this._computeTargetAndRootIntersection(n, i, e), g = null;
                this._rootContainsTarget(n) ? (!c || this.root) && (g = e) : g = p();
                var b = r.entry = new d({
                    time: _(),
                    target: n,
                    boundingClientRect: i,
                    rootBounds: g,
                    intersectionRect: v
                });
                l ? t && f ? this._hasCrossedThreshold(l, b) && this._queuedEntries.push(b) : l && l.isIntersecting && this._queuedEntries.push(b) : this._queuedEntries.push(b)
            }, this), this._queuedEntries.length && this._callback(this.takeRecords(), this)
        }
    }, o.prototype._computeTargetAndRootIntersection = function (t, e, r) {
        if (window.getComputedStyle(t).display != "none") {
            for (var n = e, i = D(t), f = !1; !f && i;) {
                var l = null, v = i.nodeType == 1 ? window.getComputedStyle(i) : {};
                if (v.display == "none") return null;
                if (i == this.root || i.nodeType == 9) if (f = !0, i == this.root || i == u) c && !this.root ? !h || h.width == 0 && h.height == 0 ? (i = null, l = null, n = null) : l = h : l = r; else {
                    var g = D(i), b = g && w(g), L = g && this._computeTargetAndRootIntersection(g, b, r);
                    b && L ? (i = g, l = E(b, L)) : (i = null, n = null)
                } else {
                    var S = i.ownerDocument;
                    i != S.body && i != S.documentElement && v.overflow != "visible" && (l = w(i))
                }
                if (l && (n = T(l, n)), !n) break;
                i = i && D(i)
            }
            return n
        }
    }, o.prototype._getRootRect = function () {
        var t;
        if (this.root && !M(this.root)) t = w(this.root); else {
            var e = M(this.root) ? this.root : u, r = e.documentElement, n = e.body;
            t = {
                top: 0,
                left: 0,
                right: r.clientWidth || n.clientWidth,
                width: r.clientWidth || n.clientWidth,
                bottom: r.clientHeight || n.clientHeight,
                height: r.clientHeight || n.clientHeight
            }
        }
        return this._expandRectByRootMargin(t)
    }, o.prototype._expandRectByRootMargin = function (t) {
        var e = this._rootMarginValues.map(function (n, i) {
            return n.unit == "px" ? n.value : n.value * (i % 2 ? t.width : t.height) / 100
        }), r = {top: t.top - e[0], right: t.right + e[1], bottom: t.bottom + e[2], left: t.left - e[3]};
        return r.width = r.right - r.left, r.height = r.bottom - r.top, r
    }, o.prototype._hasCrossedThreshold = function (t, e) {
        var r = t && t.isIntersecting ? t.intersectionRatio || 0 : -1,
            n = e.isIntersecting ? e.intersectionRatio || 0 : -1;
        if (r !== n) for (var i = 0; i < this.thresholds.length; i++) {
            var f = this.thresholds[i];
            if (f == r || f == n || f < r != f < n) return !0
        }
    }, o.prototype._rootIsInDom = function () {
        return !this.root || O(u, this.root)
    }, o.prototype._rootContainsTarget = function (t) {
        var e = this.root && (this.root.ownerDocument || this.root) || u;
        return O(e, t) && (!this.root || e == t.ownerDocument)
    }, o.prototype._registerInstance = function () {
        a.indexOf(this) < 0 && a.push(this)
    }, o.prototype._unregisterInstance = function () {
        var t = a.indexOf(this);
        t != -1 && a.splice(t, 1)
    };

    function _() {
        return window.performance && performance.now && performance.now()
    }

    function I(t, e) {
        var r = null;
        return function () {
            r || (r = setTimeout(function () {
                t(), r = null
            }, e))
        }
    }

    function y(t, e, r, n) {
        typeof t.addEventListener == "function" ? t.addEventListener(e, r, n || !1) : typeof t.attachEvent == "function" && t.attachEvent("on" + e, r)
    }

    function R(t, e, r, n) {
        typeof t.removeEventListener == "function" ? t.removeEventListener(e, r, n || !1) : typeof t.detachEvent == "function" && t.detachEvent("on" + e, r)
    }

    function T(t, e) {
        var r = Math.max(t.top, e.top), n = Math.min(t.bottom, e.bottom), i = Math.max(t.left, e.left),
            f = Math.min(t.right, e.right), l = f - i, v = n - r;
        return l >= 0 && v >= 0 && {top: r, bottom: n, left: i, right: f, width: l, height: v} || null
    }

    function w(t) {
        var e;
        try {
            e = t.getBoundingClientRect()
        } catch {
        }
        return e ? (e.width && e.height || (e = {
            top: e.top,
            right: e.right,
            bottom: e.bottom,
            left: e.left,
            width: e.right - e.left,
            height: e.bottom - e.top
        }), e) : p()
    }

    function p() {
        return {top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0}
    }

    function m(t) {
        return !t || "x" in t ? t : {
            top: t.top,
            y: t.top,
            bottom: t.bottom,
            left: t.left,
            x: t.left,
            right: t.right,
            width: t.width,
            height: t.height
        }
    }

    function E(t, e) {
        var r = e.top - t.top, n = e.left - t.left;
        return {top: r, left: n, height: e.height, width: e.width, bottom: r + e.height, right: n + e.width}
    }

    function O(t, e) {
        for (var r = e; r;) {
            if (r == t) return !0;
            r = D(r)
        }
        return !1
    }

    function D(t) {
        var e = t.parentNode;
        return t.nodeType == 9 && t != u ? s(t) : (e && e.assignedSlot && (e = e.assignedSlot.parentNode), e && e.nodeType == 11 && e.host ? e.host : e)
    }

    function M(t) {
        return t && t.nodeType === 9
    }

    window.IntersectionObserver = o, window.IntersectionObserverEntry = d
})();
var x = globalThis && globalThis.__assign || function () {
    return x = Object.assign || function (s) {
        for (var u, a = 1, c = arguments.length; a < c; a++) {
            u = arguments[a];
            for (var h in u) Object.prototype.hasOwnProperty.call(u, h) && (s[h] = u[h])
        }
        return s
    }, x.apply(this, arguments)
}, C = globalThis && globalThis.__read || function (s, u) {
    var a = typeof Symbol == "function" && s[Symbol.iterator];
    if (!a) return s;
    var c = a.call(s), h, d = [], o;
    try {
        for (; (u === void 0 || u-- > 0) && !(h = c.next()).done;) d.push(h.value)
    } catch (_) {
        o = {error: _}
    } finally {
        try {
            h && !h.done && (a = c.return) && a.call(c)
        } finally {
            if (o) throw o.error
        }
    }
    return d
}, k = globalThis && globalThis.__values || function (s) {
    var u = typeof Symbol == "function" && Symbol.iterator, a = u && s[u], c = 0;
    if (a) return a.call(s);
    if (s && typeof s.length == "number") return {
        next: function () {
            return s && c >= s.length && (s = void 0), {value: s && s[c++], done: !s}
        }
    };
    throw new TypeError(u ? "Object is not iterable." : "Symbol.iterator is not defined.")
};

function F(s, u) {
    var a = C(A.exports.useState(), 2), c = a[0], h = a[1], d = C(A.exports.useState(), 2), o = d[0], _ = d[1];
    return V(function () {
        var I = U(s);
        if (!!I) {
            var y = new IntersectionObserver(function (R) {
                var T, w;
                try {
                    for (var p = k(R), m = p.next(); !m.done; m = p.next()) {
                        var E = m.value;
                        _(E.intersectionRatio), h(E.isIntersecting)
                    }
                } catch (O) {
                    T = {error: O}
                } finally {
                    try {
                        m && !m.done && (w = p.return) && w.call(p)
                    } finally {
                        if (T) throw T.error
                    }
                }
            }, x(x({}, u), {root: U(u == null ? void 0 : u.root)}));
            return y.observe(I), function () {
                y.disconnect()
            }
        }
    }, [], s), [c, o]
}

export {F as u};